import axios from '../../libs/request'

/**
 * 搜索标题，用于搜索框实时搜索
 * @param {*} title 
 * @param {*} size 
 */
export const searchTitle = (title, pageSize = 10) => axios.request({
  url: '/api/v1/paper/title',
  method: 'get',
  params: {
    keyword: title,
    size: pageSize
  }
})

/**
 * 关键字搜索
 * @param {*} keyword 
 * @param {*} pageIndex 
 * @param {*} pageSize 
 * @param {*} highlight 
 */
export const search = (keyword, pageIndex, pageSize = 10, highlight = true) => axios.request({
  url: '/api/v1/paper',
  method: 'get',
  params: {
    keyword,
    from: pageIndex,
    size: pageSize,
    highlight
  }
})

/**
 * 根据ID获取单条论文
 * @param {*} id 
 */
export const searchById = id => axios.request({
  url: '/api/v1/paper/' + id,
  method: 'get'
})